import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ParkArticleVO, ParkArticleForm, ParkArticleQuery } from '@/api/park/parkArticle/types';

/**
 * 查询资讯列表
 * @param query
 * @returns {*}
 */

export const listParkArticle = (query?: ParkArticleQuery): AxiosPromise<ParkArticleVO[]> => {
  return request({
    url: '/park/parkArticle/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询资讯详细
 * @param articleId
 */
export const getParkArticle = (articleId: string | number): AxiosPromise<ParkArticleVO> => {
  return request({
    url: '/park/parkArticle/' + articleId,
    method: 'get'
  });
};

/**
 * 新增资讯
 * @param data
 */
export const addParkArticle = (data: ParkArticleForm) => {
  return request({
    url: '/park/parkArticle',
    method: 'post',
    data: data
  });
};

/**
 * 修改资讯
 * @param data
 */
export const updateParkArticle = (data: ParkArticleForm) => {
  return request({
    url: '/park/parkArticle',
    method: 'put',
    data: data
  });
};

/**
 * 删除资讯
 * @param articleId
 */
export const delParkArticle = (articleId: string | number | Array<string | number>) => {
  return request({
    url: '/park/parkArticle/' + articleId,
    method: 'delete'
  });
};

/**
 * 状态修改
 * @param categoryId
 * @param status
 */
export const changeStatus = (articleId: number | string, status: string) => {
  const data = {
    articleId,
    status
  };
  return request({
    url: '/park/parkArticle/changeStatus',
    method: 'put',
    data: data
  });
};
